package com.accp.vehiclecare.biz.xzhbiz;

import com.accp.vehiclecare.dao.xzhdao.ArtisansDao;
import com.accp.vehiclecare.pojo.Artisans;
import com.accp.vehiclecare.pojo.Groupclassify;
import com.accp.vehiclecare.vo.hzvo.Vehicletype;
import com.accp.vehiclecare.vo.xzhvo.ArmemberVO;
import com.accp.vehiclecare.vo.xzhvo.GroupclassifyVO;
import com.accp.vehiclecare.vo.xzhvo.arvehicleVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

@Service("ArtisansBiz")
public class ArtisansBiz extends ServiceImpl<ArtisansDao, Artisans> {
    @Autowired
    private ArtisansDao artisansDao;

    /**
     * 查询班组信息
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public List<GroupclassifyVO> queryArtisans(){
        return artisansDao.queryArtisans();
    }

    /**
     * 查询班组成员
     * @param artisansid
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public PageInfo<ArmemberVO> queryArmember(Integer artisansid,Integer PageNum,Integer PageSize,String armembername){
        PageHelper.startPage(PageNum,PageSize);
        return new PageInfo<ArmemberVO>(artisansDao.queryArmember(artisansid,armembername));
    }

    /**
     * 查询班组
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public List<Artisans> queryShift(){
        return artisansDao.queryShift();
    }

    /**
     * 查询班组类别
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public List<Groupclassify>queryGroupClassIfy(){
        return artisansDao.queryGroupClassIfy();
    }

    /**
     * 新增班组
     * @param artisans
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean addArtisans(Artisans artisans){
        int count = super.baseMapper.insert(artisans);
        return count !=0;
    }

    /**
     * 修改班组
     * @param artisans
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean ModifyArtisans(Artisans artisans){
        int count = super.baseMapper.updateById(artisans);
        return count !=0;
    }

    /**
     * 删除班组
     * @param artisansid
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean deleteArtisans(Integer artisansid){
        int count=artisansDao.deleteArtisans(artisansid);
        return count!=0;
    }

    /**
     * 查询车辆型号
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public  List<Vehicletype> queryVehicleType(){
        return artisansDao.queryVehicleType();
    }

    /**
     * 查询外勤车辆
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED, readOnly = true)
    public List<arvehicleVO> queryArvehicle(){
        return artisansDao.queryArvehicle();
    }


}
